package com.example.back.controller;

import com.example.back.entity.Notice;
import com.example.back.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;

@RestController
public class NoticeController {
    @Autowired
    private NoticeService noticeService;

    @PostMapping("/notice")
    public int addNotice(Notice notice){
        return noticeService.addNotice(notice);
    }

    @DeleteMapping("/notice/{id}")
    public int deleteNotice(@PathVariable("id") Serializable id){
        return noticeService.deleteNotice(id);
    }

    @PutMapping("/notice")
    public int updateNotice(Notice notice){
        return noticeService.updateNotice(notice);
    }

    @GetMapping("/notice/{id}")
    public Notice selectNoticeById(@PathVariable("id") Serializable id){
        return noticeService.selectNoticeById(id);
    }

    @GetMapping("/notice")
    public ArrayList<Notice> selectNotice(Notice notice){
        return noticeService.selectNotice(notice);
    }
}
